<?php
/**
 * 内容管理视图
 *
 *
 *
 */
// 排序
$arr_orderby    = array(
    'id'        => '&orderby=id',
    'aid'       => '&orderby=aid',
    'lxname'   => '&orderby=lxname',
    'lxphone'    => '&orderby=lxphone',
    'ctime' => '&orderby=ctime',
    'lxqq'   => '&orderby=lxqq',
    );
$orderby    = strtolower(trim(@$_GET['orderby']));
if(array_key_exists($orderby, $arr_orderby)) {
    $order_asc  = @(int)$_GET['desc'];
    $arr_orderby[$orderby] .= $order_asc == 0 ? '&desc=1' : '&desc=0';
} else {
    $arr_orderby['id'] .= '&desc=0';
}

// 保存数据框架名
$save_frame = $_SESSION[$G_admin_session_key]['save_frame'];
$back_url   = get_current_url();
// 将当前URL保存在Cookie中，避免复杂的URL字符串
cookie('back_url', strcode($back_url));
$url_cur    = get_current_url(array('orderby', 'desc'));


/**
 * 搜索参数处理
 *
 */
// 关键字
$key            = trim(@$_GET['key']);
// 是否包含子类
$class_id       = @(int)$_GET['class_id'];
$class_all      = @(int)$_GET['class_all'];
$chk_class_all  = ($class_all==1) ? ' checked' : '';
// 是否有效
$display       = trim(@$_GET['display']);
$chk_display_all   = '';
$chk_display__1    = '';
$chk_display_1     = '';
if($display == -1) {
    $chk_display__1 = ' checked';
} elseif($display == 1) {
    $chk_display_1 = ' checked';
} else {
    $chk_display_all = ' checked';
}


$begin_date = @$_GET['begin_date'];
$end_date   = @$_GET['end_date'];

// + -------------------------------------- + //
// 排序处理 - 为排序加上小图标

$order_by   = @trim($_GET['orderby']);
$order_desc = @(int)$_GET['desc'];

if($order_by != '') {
    $order_desc = ($order_desc!=1) ? 'sort_asc' : 'sort_desc' ;
    $this_param_style  = $order_by . '_style';
    $$this_param_style = '<div class="' . $order_desc . '"></div>';
}

// + -------------------------------------- + //

require('header.php');
?>
<SCRIPT LANGUAGE="JavaScript" SRC="<?php echo $url_global['common'] ?>/js/popcalendar.js"></SCRIPT>





<div class="sp_height_5px"></div>
<div class="datacontainer1" id="listDiv">
<form action="<?php echo $mod_url['li'] ?>" name="search" method="get">
<div class="new_line">
<input type="hidden" name="mod" value="<?php echo $mod ?>">
<input type="hidden" name="action" value="<?php echo $action ?>">
<input type="hidden" name="cata" value="<?php echo $cata ?>">



	<div class="spW10 fl"></div>
	
	&nbsp;&nbsp;
</div>
</form>

<form action="<?php echo $mod_url['del'] ?>" name="items_form" method="post" target="<?php echo $save_frame?>" onsubmit="return del_select_items(this.name, 'item_id[]');">
<TABLE BORDER="0" CELLPADDING="4" CELLSPACING="1" width="100%" class="list_table">
<THEAD>
	<TR class="list_head">
		<TH scope=col width="30"><a href="<?php echo $url_cur ?><?php echo $arr_orderby['id'] ?>"><?php echo $id_style;?>#</a></TH>
        <TH scope=col width="95"><a href="<?php echo $url_cur ?><?php echo $arr_orderby['sender'] ?>"><?php echo $sender_style;?>联系姓名</a></TH>
        <TH scope=col width="103"><a href="<?php echo $url_cur ?><?php echo $arr_orderby['sender'] ?>"><?php echo $sender_style;?>联系电话</a></TH>
        <TH scope=col width="80"><a href="<?php echo $url_cur ?><?php echo $arr_orderby['sender'] ?>"><?php echo $sender_style;?>联系QQ</a></TH>
		<TH scope=col width="109"><a href="<?php echo $url_cur ?><?php echo $arr_orderby['sendtime'] ?>"><?php echo $sendtime_style;?>发布时间</a></TH>
		<TH width="602" scope=col><a href="<?php echo $url_cur ?><?php echo $arr_orderby['subject'] ?>"><?php echo $subject_style;?>意向项目</a></TH>
		<TH scope=col width="89">操作</TH></TR></THEAD>
<TBODY>
<?php
$tr_class   = '';
if(!empty($record) && sizeof($record) > 0) {
    foreach($record as $k=>$v) {
        $tr_class   = $tr_class != 'tr0' ? 'tr0' : 'tr1';
        $id         = $v['id'];
        $subject    = getxmtitle($v['aid']);
        $aid        = $v['aid'];
        $lxphone        = $v['lxphone'];
        $lxname     = htmlspecialchars($v['lxname']);
        if($lxname == '') $lxname = '&nbsp;';
        $ctime  = $v['ctime'] > 0 ? date(DATE_FORMAT, $v['ctime']) : '未知';
        $lxqq    = $v['lxqq'];
		//$brand      = $v['brand'];
        // 截取
        $subject_cut    = (zh_strlen($subject)>=48)? zh_substr($subject, 47) : $subject;

?>
	<TR class="<?php echo $tr_class; ?>" onmouseover="return chgBg(this, 1);" onmouseout="return chgBg(this, 0);">
		<TD width="30" class="textC"><input type="checkbox" value="<?php echo $id ?>" name="item_id[]"></TD>
		<TD width="95" align="center"><?php echo $lxname ?></TD>
		<TD width="103" class="time01 textC"><?php echo $lxphone ?></TD>
		<TD width="80" class="time01 textC"><?php echo $lxqq ?></TD>
		<TD width="109" class="time01 textC"><?php echo $ctime ?></TD>
		<TD>&nbsp;<a target="_blank" href="/projects/display.php?aid=<?php echo $aid ?>"><?php echo $subject_cut;?></span></TD>
		<TD width="89" align="center" class="textC">
			<a href="?mod=xmyx&action=modify&id=<?php echo $id ?>" class="btn_modify fl" title="内容">查看</a> 
			<a href="<?php echo $mod_url['del'] ?>&item_id=<?php echo $id ?>" target="<?php echo $save_frame ?>" onclick="return del_this();" class="btn_del fl" title="删除内容">删除</a>
		</TD></TR>
<?php
    }
} else {
?>
<TR class="tr0" onmouseover="return chgBg(this, 1);" onmouseout="return chgBg(this, 0);">
<TD colspan="8">没有或没有找到合适的记录！</TD>
</TR>
<?php
}
?>
</TBODY>
</TABLE>
<?php
// 分页
$page_info  = "共 $record_total 条记录 每页 $page_size 条 共 $page_total 页 ";
$page_list  = get_page_nav($page_total);
?>
<div class="page_nav">
	<div class="page_info">
		<?php echo $page_info; ?>
	</div>
	<div class="page_list_pre">
		&nbsp;&nbsp;<a href="javascript:void(0);" onclick="chkbox_sel_all('items_form', 'item_id[]');"><B>全选</B></a> <a href="javascript:void(0);" onclick="chkbox_sel_reverse('items_form', 'item_id[]');"><B>反选</B></a>
	</div>
	<div class="page_list">
		<?php echo $page_list; ?>
	</div>
</div>

<div class="new_line">
<input type="submit" name="del" value="删除" class="btn fl">
<input type="hidden" name="deltype" value="all">

</div>
</form>
		</div>
</div>

<?php
require('footer.php');
?>